package com.java.test.initialization;

/**
 * @author TonyOne
 * @version 1.0
 * @desc
 * @date 2018/10/26 11:41
 * @company
 */
public class InitializeOrder {
    public static void main(String[] args) {
        new TestB(3);
    }
}

class TestA {
    private static int a =1;
    static {
        System.out.println("父类静态代码块：a="+a);
    }
    {
        System.out.println("父类代码块：a="+a);
        System.out.println("父类代码块：this.a="+this.a);
    }

    public TestA(int a) {
        this.a=a;
        System.out.println("父类构造函数：a="+a);
        System.out.println("父类构造函数：this.a="+this.a);
    }
}

class TestB extends TestA{
    private static int a =2;
    {
        System.out.println("子类代码块：a="+a);
        System.out.println("子类代码块：this.a="+this.a);
    }
    static {
        System.out.println("子类静态代码块：a="+a);
    }

    public TestB(int a) {
        super(a);
        this.a=a;
        System.out.println("子类构造函数：a="+a);
        System.out.println("子类构造函数：this.a="+this.a);
    }
}
